package text111;

import java.util.HashMap;

public class Solution9 {
	  public char firstUniqChar(String s) {
		/*
		 * char res = ' '; char[] str = new char[s.length()]; str = s.toCharArray();
		 * 
		 * 
		 * for (int i = 0; i < str.length; i++) { int t = 0; for (int j = i+1; j <
		 * str.length; j++) {
		 * 
		 * if (str[i]==str[j]) { t++; } } System.out.println(t); if (t==0 ) { res =
		 * str[i]; break; } }
		 * 
		 * return res;
		 */
		  HashMap<Character, Boolean> dic = new HashMap<>();
	        char[] sc = s.toCharArray();
	        for(char c : sc)
	            dic.put(c, !dic.containsKey(c));
	        for(char c : sc)
	            if(dic.get(c)) return c;
	        return ' ';
	
	    }
}
